package com.newtouch.ainsurtech.listener;





import com.newtouch.ainsurtech.BaseEntity;

import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import java.util.Date;

/**
 * 描述:BaseEntityListener
 * 模型监听
 *
 * @author ziv.hung create on 16/8/29
 * @since 1.0
 */
public class BaseEntityListener {

    @PreUpdate
    public void preUpdate(BaseEntity entity) {
        Date modifyTime = new Date();
        entity.setModifyTime(modifyTime);
    }

    @PrePersist
    public void prePersist(BaseEntity entity) {
        Date insertTime = new Date();
        entity.setInsertTime(insertTime);
    }
}